import $http from '../../utils/request';



//获取商品并分页，搜索
export const comStrPager = (query: any, c: any) => {
    let url = `pager?pageNum=${query.pageIndex}&pageSize=${query.pageSize}`;
    url += `&id=${c.id}&name=${c.name}&price=${c.price}&kg=${c.kg}&img1=${c.img1}&img2=${c.img2}&img3=${c.img3}&img4=${c.img4}&date=${c.date}&xx=${c.xx}&num=${c.num}&sj=${c.sj}&kg_kg=${c.k.kg_kg}&image2=${c.image.image2}&image3=${c.image.image3}&image4=${c.image.image4}&image5=${c.image.image5}&image6=${c.image.image6}&image7=${c.image.image7}`
    return $http({
        url: "C/"+url,
        method: 'get'
    });
};

//获取用户并分页，搜索
export const userStrPager = (query: any, m: any) => {
    let url = `pager?pageNum=${query.pageIndex}&pageSize=${query.pageSize}`;
    url += `&id=${m.id}&user=${m.user}&qq=${m.qq}&pass=${m.pass}&date=${m.date}&mail_img=${m.mail_img}`
    return $http({
        url: "U/"+url,
        method: 'get'
    });
};
//获取用户评论，搜索
export const plStrPager = (query: any, p: any) => {
    let url = `pager?pageNum=${query.pageIndex}&pageSize=${query.pageSize}`;
    url += `&pl_id=${p.pl_id}&pl_plnr=${p.pl_plnr}&pl_date=${p.pl_date}&pl_qq=${p.pl_qq}&pl_sp_id=${p.pl_sp_id}&name=${p.commodity.name}&img=${p.commodity.img}&mail_img=${p.mail.mail_img}`
    return $http({
        url: "P/"+url,
        method: 'get'
    });
};
//获取用户订单，搜索
export const ddStrPager = (query: any, d: any) => {
    let url = `pager?pageNum=${query.pageIndex}&pageSize=${query.pageSize}`;
    url += `&dd_id=${d.dd_id}&dd_hao=${d.dd_hao}&dd_ip=${d.dd_ip}&dd_date=${d.dd_date}&dd_zf=${d.dd_zf}&dd_name=${d.dd_name}&dd_xxip=${d.dd_xxip}&dd_qq=${d.dd_qq}&dd_phone=${d.dd_phone}`
    return $http({
        url: "Dd/"+url,
        method: 'get'
    });
};

//添加学生
export const addShang = (student: any) => {
    return $http.post("C/", student)
}

//添加/修改图片
export const file_ = (form_data: any) => {
    return $http.post("upfile/files", form_data, {
        headers: {
            'Content-Type': 'multipart/form-data',
        },
    });
};

//删除商品
export const deleteSp = (id: string) => {
    return $http.delete(`C/${id}`);
}
//删除用户
export const deleteU = (id: string) => {
    return $http.delete(`U/${id}`);
}
//修改数据
export const upStudent = (student: any) => {
    return $http.put(`C/`, student);
}

//修改商品上下架状态
export const upSj = (student: any) => {
    return $http.put(`C/sj/`, student);
}

//导入Excel文件
export const importExcel = (formData: any) => {
    return $http.post("http://127.0.0.1:1234/C/importExcel", formData, {
        headers: {"Content-Type": "multipart/form-data"}
    })
}

//批量删除
export  const deleteStudents=(ids:string[])=>{
    return $http.post(`deletes`,ids);
}
export const getAllUser = () => {
    return $http.get('pager');
};
export const handleDelete = (stu: any) => {
    return $http.get(`pager/${stu.id}`);
};
